﻿namespace AltNetUK.Web.Routing
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Globalization;
    using System.Reflection;
    using System.Web.Mvc;
    using System.Web.Routing;
    using AltNetUK.Controllers;
    using SimpleWebServices.Web.Mvc;
    using SimpleWebServices.Web.Routing;

    public static class RouteCollectionExtensionMethods
    {
        public static void Register(this RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Register<RedirectController>(string.Empty, new { action = "SeeOther", path = "2009" });
            routes.Register<FaviconController>("favicon.ico");
            routes.Register<RobotsController>("robots.txt");
            routes.Register<SiteMapController>("sitemap.xml");
            routes.Register<EmptyHtmlController>("google14a19b0fae46a407.html");

            routes.RegisterHtml("2009[extension]", "Home");

            #region event

            routes.Register(
                "{date}.ics",
                new { controller = "Event", action = "CalendarRepresentation" },
                new { date = @"\d{4}-\d{2}-\d{2}" });
            routes.RegisterHtml("{date}[extension]", "Event", new { date = @"\d{4}-\d{2}-\d{2}" });
            
            #endregion

            #region registration

            routes.RegisterPost("registration", "Registration");
            routes.RegisterHtml(
                "registration[extension]/{identifier}",
                "Registration",
                new { unique = @"\w{8}-\w{4}-\w{4}-\w{4}-\w{12}" });
            routes.RegisterHtml("registration[extension]", "Registration");

            #endregion

            routes.Register<NotFoundController>("{*url}", new { controller = "NotFound", action = "HtmlRepresentation" });
        }
    }
}